package textDisplay;

import processing.core.*;
import static processing.core.PConstants.*;

public class ScreenText {
	public PApplet parent;
	public String text;
	public PFont font;
	public int fontSize;
	public int color;
	public int framesToGo;
	public int xLoc, yLoc;
	public int align, yalign;
	
	public ScreenText(PApplet p, String t, PFont ft, int s, int c, int f, int x, int y, int a, int ya) {
		parent = p; text = t; font = ft; fontSize = s;
		color = c; framesToGo = f;
		xLoc = x; yLoc = y; align = a; yalign = ya;
	}
	
	public void draw() {
		parent.textMode(SCREEN);
		parent.textFont(font, fontSize);
		parent.textAlign(align, yalign);
		int col = color;
		if (framesToGo>0) {
			framesToGo--;
			if (framesToGo<parent.frameRate/2) {
				col = parent.color(parent.red(color), parent.blue(color), 
						parent.green(color), 255*2*framesToGo/parent.frameRate);
			}
		}
		parent.stroke(col);
		parent.fill(col);
		parent.text(text, xLoc, yLoc);
	}
}
